﻿using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;

namespace IdentityAtRest.Utility.Identity.Wcf
{
    public class ClientAuthBehavior : IEndpointBehavior
    {
        private readonly ClientAuthMessageInspector _messageInspector;

        public ClientAuthBehavior() : this(new ClientAuthMessageInspector())
        {
        }

        public ClientAuthBehavior(ClientAuthMessageInspector messageInspector)
        {
            _messageInspector = messageInspector;
        }

        #region IEndpointBehavior Members

        public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
        {
            //Install the message inspector
            clientRuntime.MessageInspectors.Add(_messageInspector);
        }

        public void Validate(ServiceEndpoint endpoint)
        {
            //nop
            return;
        }

        public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
        {
            //nop
            return;
        }

        public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
        {
            //nop
            return;
        }

       
        #endregion
    }
}